package poker;

public class Card implements Comparable<Card> {

	private char suit;
	private int value;
	
	public Card(char initSuit, int initValue)
	{
		suit = Character.toLowerCase(initSuit);
		value = initValue;
	}
	
	public char getSuit() {return suit;}
	
	public int getValue() {return value;}
	
	public String toString()
	{
		String stringValue;
		String cardString;
		
		if(value == 14) {stringValue = "A";}
		else if(value == 13) {stringValue = "K";}
		else if(value == 12) {stringValue = "Q";}
		else if(value == 11) {stringValue = "J";}
		else {stringValue = String.valueOf(value);}
		
		cardString = stringValue + suit;
		
		return cardString;
	}

	@Override
	public int compareTo(Card card) {
		return card.value - this.value;
	}
	
	public static void printCards(Card[] cards, int startPosition, int length) 
	{
		for (int i = startPosition; i < startPosition + length; i++) {
			System.out.print(cards[i] + " ");
		}
	}
	
	public static void printCards(Card[] cards) 
	{
		printCards(cards, 0, cards.length);
	}
	
	@Override
	public boolean equals(Object obj) 
	{
		if(obj instanceof Card)
		{
			Card otherCard = (Card)obj;
			return (this.getValue() == otherCard.getValue() && this.getSuit() == otherCard.getSuit());
		}
		else
			return false;
	}
}
